package com.shuimutong.gutil.common;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 通用工具
 * @ClassName:  CommonUtil   
 * @Description:(这里用一句话描述这个类的作用)   
 * @author: 水木桶
 * @date:   2019年9月7日 下午4:16:10     
 * @Copyright: 2019 [水木桶]  All rights reserved.
 */
public class GUtilCommonUtil {
	/**
	 * 检测列表是否为空
	 * @param list
	 * @return
	 */
	public static <T> boolean checkListEmpty(Collection<T> list) {
		if (list == null || list.isEmpty()) {
			return true;
		}
		return false;
	}

	public static <T> boolean checkListEmpty(T[] list) {
		if (list == null || list.length == 0) {
			return true;
		}
		return false;
	}

	public static <T, G> boolean checkListEmpty(Map<T, G> map) {
		if (map == null || map.isEmpty()) {
			return true;
		}
		return false;
	}
	
	public static List<String> readFile(String path) throws Exception {
		List<String> list = new ArrayList();
		BufferedReader br = null;
		String line;
		try {
			br = new BufferedReader(new FileReader(path));
			while ((line = br.readLine()) != null) {
				list.add(line);
			}
		} catch (Exception e) {
			throw e;
		} finally {
			if (br != null) {
				br.close();
			}
		}
		return list;
	}
}
